#! /usr/bin/env python
#-*- coding: utf-8 -*-


class Stack(object) :
    def __init__(self) :
        self.stack = []

    def push(self, item) :
        self.stack.append(item)

    def pop(self) :
        if self.stack != [] :
            return self.stack.pop(-1)
        else :
            return None

    def top(self) :
        if self.stack != [] :
            return self.stack[-1]
        else :
            return None

    def length(self) :
        return len(self.stack)

    def isempty(self) :
        return self.stack == []


class Queue(object) :
    def __init__(self) :
        self.queue = []

    def enqueue(self, item) :
        self.queue.append(item)

    def dequeue(self) :
        if self.queue != [] :
            return self.queue.pop(0)
        else :
            return None

    def head(self) :
        if self.queue != [] :
            return self.queue[0]
        else :
            return None

    def tail(self) :
        if self.queue != [] :
            return self.queue[-1]
        else :
            return None

    def length(self) :
        return len(self.queue)

    def isempty(self) :
        return self.queue == []


s = Stack()    # get a stack
q = Queue()    # get a queue

for i in range(10) :
    s.push(i)
    q.enqueue(i)

# stack s
print 'length of stack s is %d' %s.length()
print 'top of stack s is %d' %s.top()
print 'pop an item %d from stack s' %s.pop()
print 'now, top of stack s is %d' %s.top()

print

#queue q
print 'length of queue q is %d' %q.length()
print 'head of queue q is %d' %q.head()
print 'tail of queue q is %d' %q.tail()
print 'del an item %d from queue q' %q.dequeue()
print 'now, head of queue q is %d' %q.head()
print 'tail of queue q is %d' %q.tail()
